#include <iostream>

using namespace std;

#define N 5

int a[5];

/*
void print_set(int cur)
{
	if (N == cur)
	{
		for (int i = 0; i < cur; ++i)
		{
			if (a[i])
			{
				cout << i << " ";
			}
		}
		cout << endl;
		return;
	}

	a[cur] = 1;
	print_set(cur + 1);
	a[cur] = 0;
	print_set(cur + 1);
}
*/

void print_set(int cur)
{
	for (int i = 0; i < cur; ++i)
	{
		cout << a[i] << " ";
	}
	cout << endl;

	int s = 0;
	if (cur == 0)
	{
		s = 0;
	}
	else if (cur > 0)
	{
		s = a[cur - 1] + 1;
	}
	for (int i = s; i < N; ++i)
	{
		a[cur] = i;
		print_set(cur + 1);
	}
}

int main()
{
	print_set(0);
	return 0;
}
